package com.ruibei.ui.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;

import com.ruibei.R;
import com.ruibei.models.ListItemModel;
/**
 * 
 * @author wu
 *	列表适配器
 */
public class ListItemAdapter extends BaseAdapter{
	private LayoutInflater mInflater;
	private List<ListItemModel> listItemModel;
	private Context context;

	public ListItemAdapter(Activity context, List<ListItemModel> listItemModel) {
		this.context = context;
		mInflater = LayoutInflater.from(context);
		this.listItemModel = listItemModel;
	}

	public void setmessageBeanList(List<ListItemModel> listItemModel) {
		this.listItemModel = listItemModel;
	}

	@Override
	public int getCount() {
		return listItemModel.size();
	}

	@Override
	public Object getItem(int position) {
		return listItemModel.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ListItemModel task = listItemModel.get(position);
		//Integer ppCount = MessageBean.getNoticeSum();
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.list_item_layout, null);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.item_date.setText(task.getDate());
		holder.item_content.setText(task.getContent());
		holder.item_title.setText(task.getTitle());
		
		

		 
		 
		
		return convertView;
	}

	static class ViewHolder {
	
		@InjectView(R.id.list_item_date) TextView item_date;
		@InjectView(R.id.list_item_image) ImageView item_image;
		@InjectView(R.id.list_item_title) TextView item_title;
		@InjectView(R.id.list_item_content) TextView item_content;
		
	
		 

		public ViewHolder(View view) {
	
		ButterKnife.inject(this, view);
	
		}

		}
}
